// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129

module.exports = {
	_before: function() { // 通用预处理器

	},
	/**
	 * 获取课程列表
	 */
	async getList(skip = 0, limit = 8) {
		const dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		let res = await dbJQL.collection("course")
			.field("name,type,subject,auth,imageUrl,pubTime,price,enPrice,like_count,createTime")
			.orderBy("createTime desc")
			.skip(skip)
			.limit(limit)
			.get();
		return res;
	},
	/**
	 * 获取课程详情
	 */
	async getDetail(id) {
		const dbJQL = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		let res = await dbJQL.collection("course").doc(id).get({
			getOne: true
		});
		return res;
	}
}